#include "plugin.h"
#include "BasePlugin.h"
#include "FixPlugin.h"
#include <windows.h>

HINSTANCE		hInstance;
BasePlugin *plugin = NULL;

char* EVENT_LOAD = "load";
char* EVENT_INITIALLOAD = "initialLoad";
char* EVENT_START = "start";
char* EVENT_STOP = "start";
char* EVENT_UNLOAD = "unload";
char* EVENT_FINALUNLOAD = "finalUnload";

int __declspec(dllexport)plugin_main(char *event, void *data) 
{   
	if (strequal(event, EVENT_LOAD)){
		plugin_info_t *plugin_info = (plugin_info_t*)data;
		plugin = new FixPlugin();
		plugin->Load(plugin_info);
	}	else if (strequal(event, EVENT_INITIALLOAD)){
		plugin->InitialLoad();
	} else if (strequal(event, EVENT_START)){
		plugin->Start();
	} else if (strequal(event, EVENT_STOP)){
		plugin->Stop();
	} else if (strequal(event, EVENT_UNLOAD)){
		plugin->Unload();
	} else if (strequal(event, EVENT_FINALUNLOAD)){
		plugin->FinalUnload();
	}
	return 0;
}

int __declspec(dllexport)plugin_version(void)
{
	return 1;
}

int WINAPI DllMain(HANDLE hinstDLL, unsigned long dwReason, void *reserved)
{
	hInstance = (HINSTANCE)hinstDLL;

	switch (dwReason) {

		case DLL_THREAD_DETACH:
			break;

        case DLL_PROCESS_DETACH:
			break;
	}

	return 1;
}